<?php require_once(dirname(__FILE__)."/../config/config.php"); ?>
<?php 
if(!empty($_POST['Submit'])){
	$admin_name=$_POST['admin_name'];
	$admin_password=$_POST['admin_password'];
	$sql="select * from zy_admin where admin_name='".$admin_name."' and admin_password='".$admin_password."' limit 0,1";
	$result = mysql_query($sql);
	$num = mysql_num_rows($result);
	if($num){               //如果用户存在，就检查密码是否正确
		$rs = mysql_fetch_array($result);
    	if($rs['admin_name']!=$admin_name || $rs['admin_password']!=$admin_password){
		   echo "用户名或密码有误，请确认后输";
    	}else{                //用户名，密码都正确，注册SESSION变量，然后跳转到首页
			$_SESSION['admin_name']=$admin_name;
			echo "<script>location.href='index.php';</script>";
		}
	}else{                        //如果没有这个用户
		echo "用户名或密码有误，请确认后输入！";
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理员登录</title>
</head>
<body>
<h1 align="center">管理员登录</h1>
---------------------------------------------------------------------------------------------------------------------------
<form id="form1" name="form1" method="post" action="">
  <p align="center">管理员账号：
    <input name="admin_name" type="text" id="admin_name" />
  </p>
  <p align="center">管理员密码：
    <input name="admin_password" type="password" id="admin_password" />
  </p>
  <p align="center">
    <input type="submit" name="Submit" value="提交" />
  </p>
</form>
</body>
</html>
